package com.jxt.myjxtmanager.ui.presenter;

import android.content.Context;


import com.jxt.myjxtmanager.entity.AskForLeaveBean;
import com.jxt.myjxtmanager.ui.inter.AskLeaveInter;
import com.jxt.myjxtmanager.ui.model.AskLeaveMo;
import com.jxt.myjxtmanager.views.CustomProgressDialog;

import java.util.List;

/**
 * Created by qm on 2017/3/13 0013.
 */
public class AskLeavePresenter implements AskLeaveMo.OnFindAllDataListener{
    private final CustomProgressDialog dialog;
    private AskLeaveMo askLeaveMo;
    private AskLeaveInter inter;

    public AskLeavePresenter(Context cxt, AskLeaveInter inter) {
        this.inter = inter;
        askLeaveMo = new AskLeaveMo(cxt);
        askLeaveMo.setOnFindAllDevicesListener(this);
        dialog = new CustomProgressDialog(cxt, "");
    }

    public List<AskForLeaveBean> getDataList() {
        return askLeaveMo.getQueryList();
    }

    public void dismissDialog() {
        if (dialog != null) {
            dialog.dismiss();
        }
    }

    public void RefreshDatas(){
        if (dialog != null) {
            dialog.showDialog();
        }
        askLeaveMo.RefreshData();
    }
    public void RequestData() {
        if (dialog != null) {
            dialog.showDialog();
        }
        askLeaveMo.RequestData();
    }
    public void RequestStudentData() {
        if (dialog != null) {
            dialog.showDialog();
        }
        askLeaveMo.RequestStudentData();
    }

    @Override
    public void onFindSuccess() {
        inter.setMyAdapter();
    }

    @Override
    public void OnFindAllDataSuccess(String strTitle) {
        inter.updateRecycler();
    }

    @Override
    public void onFailure() {

    }

    @Override
    public void onError() {

    }
}
